#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T;
int n,m,L,V;
int d[N],v[N],a[N],det[N],ans1,ans2;
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        ans1=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>det[i];
        }
        if(a[1]==0){
            for(int i=1;i<=n;i++){
                if(v[i]>V)ans1++;
            }
            cout<<ans1<<" "<<m-1<<endl;
        }
        else if(a[1]<0){
            for(int i=1;i<=n;i++){
                if(v[i]>V){
                    double tmp=(V*V-v[i]*v[i])*1.0/(2.0*a[i])+d[i];
                    if(tmp>det[1])ans1++;
                }
            }
            cout<<ans1<<" "<<m/2<<endl;
        }
        else {
            for(int i=1;i<=n;i++){
                double tmp=(V*V-v[i]*v[i])*1.0/(2.0*a[i])+d[i];
                if(tmp<L&&tmp<det[m])ans1++;
            }
            cout<<ans1<<" "<<m-1<<endl;
        }
    }
    return 0;
}
